package belf.migrate.engine.job.jdbc;

public interface Pipe {
    public String name();

    public void put(Object o);

    public Object pop();

    public void setTotal(long total);

    public long getTotal();

    public void readCount(long count);

    public default long getRead() {
        return 0;
    }

    public default long getCached() {
        return 0;
    }

    public void wroteCount(long count);

    public default long getWrote() {
        return 0;
    }

    public default String getStatus() {
        double read_percentage = 0;
        double wrote_percentage = 0;
        if (getTotal() != 0) {
            read_percentage = ((double) getRead() / getTotal()) * 100;
            wrote_percentage = ((double) getWrote() / getTotal()) * 100;
        }
        return String.format("Table: %s, Rows: %d, Read: %d / %.2f%%, Queue: %d, Wrote: %d / %.2f%%", name(), getTotal(), getRead(), read_percentage, getCached(), getWrote(), wrote_percentage);
//        return String.format("表: %s, 行数: %d, 已读: %d / %.2f%%, 队列: %d, 已写: %d / %.2f%%", name(), getTotal(), getRead(), read_percentage, getCached(), getWrote(), wrote_percentage);
    }

}